var html_temp = '';
jQuery(function() {
  click_btn_following_user();
  click_change_account_info();
  click_change_upload_avatar();
  click_change_account_info();
  if (jQuery('#latest-jcarousel_1').length > 0) {
    jQuery('#latest-jcarousel_1').jcarousel({
      visible: 4
    });
  }
  if (jQuery('#latest-jcarousel_2').length > 0) {
    jQuery('#latest-jcarousel_2').jcarousel({
      visible: 4
    });
  }
});

function click_change_upload_avatar() {
  var url = 'http://' + location.hostname + Drupal.settings.basePath;
  jQuery('.avatar_change').click(function() {
    jQuery('#dialog_box').dialog({
      autoOpen: true,
      title: 'Upload Avatar',
      modal: true,
      width: 600,
      height:300
    });
    var data = jQuery.ajax({
      type: "POST",
      url:url + 'customer/get_form_upload_avatar',
      async:false
    }).responseText;
    jQuery('#dialog_box').html(data);
  });
}

function click_change_account_info() {
  var url = 'http://' + location.hostname + Drupal.settings.basePath;
  jQuery('#btn_edit_account_info').click(function() {
    jQuery('#dialog_box').dialog({
      autoOpen: true,
      title: 'Edit account',
      modal: true,
      width: 600,
      height:570,
      buttons: {
        'Save': function() {
          var data = jQuery.ajax({
            type: "POST",
            data: {name: jQuery('#name').val(),
              surname:jQuery('#surname').val(),
              sports:jQuery('#sports').val(),
              age:jQuery('#age').val(),
              about:jQuery('#about').val(),
              goals:jQuery('#goals').val(),
              interested:jQuery('#interested').val()
            },
            url:url + 'ajax/customer/edit',
            async:false
          }).responseText;
          window.location.reload();
        },
        'Cancel': function() {
          jQuery('#dialog_box').dialog('close');
        }
      }
    });
    var data = jQuery.ajax({
      type: "POST",
      url:url + 'customer/get_form_edit_account',
      async:false
    }).responseText;
    jQuery('#dialog_box').html(data);
  });
}

function click_btn_following_user() {
  jQuery('#following_user').click(function() {
    var url = 'http://' + location.hostname + Drupal.settings.basePath;
    var follow_id = jQuery(this).attr('id_follow');
    alert(follow_id);
    var data = jQuery.ajax({
      type: "POST",
      url:url + 'customer_following_other',
      data: {follow_id:follow_id},
      async:false
    }).responseText;
    alert(data);
  });
}

